package com.gg.registration.model.hosp;

import com.alibaba.fastjson.JSONArray;
import lombok.Data;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.util.StringUtils;

import java.util.List;
import java.util.Objects;

/**
 * <p>
 * RegisterRule
 * </p>
 *
 * @author qy
 */
@Data
@Document("BookingRule")
public class BookingRule {
	
	private Integer cycle;

	private String releaseTime;

	private String stopTime;

	private Integer quitDay;

	private String quitTime;

	private List<String> rule;

	/**
	 *
	 * @param rule
	 */
	public void setRule(String rule) {
		if(!StringUtils.isEmpty(rule)) {
			this.rule = JSONArray.parseArray(rule, String.class);
		}
	}

	public BookingRule() {
	}

	@Override
	public String toString() {
		return "BookingRule{" +
				"cycle=" + cycle +
				", releaseTime='" + releaseTime + '\'' +
				", stopTime='" + stopTime + '\'' +
				", quitDay=" + quitDay +
				", quitTime='" + quitTime + '\'' +
				", rule=" + rule +
				'}';
	}

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;
		BookingRule that = (BookingRule) o;
		return Objects.equals(cycle, that.cycle) &&
				Objects.equals(releaseTime, that.releaseTime) &&
				Objects.equals(stopTime, that.stopTime) &&
				Objects.equals(quitDay, that.quitDay) &&
				Objects.equals(quitTime, that.quitTime) &&
				Objects.equals(rule, that.rule);
	}

	@Override
	public int hashCode() {
		return Objects.hash(cycle, releaseTime, stopTime, quitDay, quitTime, rule);
	}

	public Integer getCycle() {
		return cycle;
	}

	public void setCycle(Integer cycle) {
		this.cycle = cycle;
	}

	public String getReleaseTime() {
		return releaseTime;
	}

	public void setReleaseTime(String releaseTime) {
		this.releaseTime = releaseTime;
	}

	public String getStopTime() {
		return stopTime;
	}

	public void setStopTime(String stopTime) {
		this.stopTime = stopTime;
	}

	public Integer getQuitDay() {
		return quitDay;
	}

	public void setQuitDay(Integer quitDay) {
		this.quitDay = quitDay;
	}

	public String getQuitTime() {
		return quitTime;
	}

	public void setQuitTime(String quitTime) {
		this.quitTime = quitTime;
	}

	public List<String> getRule() {
		return rule;
	}

	public void setRule(List<String> rule) {
		this.rule = rule;
	}
}

